package com.daidai.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.daidai.model.Activity;
import com.daidai.model.ActivityDTO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * Author: Mr.Chen
 * Date: 2022/08/01 9:26
 * Description:
 */
@Mapper
public interface ActivityDao extends BaseMapper<Activity> {

    @Select("select * from activity ac,(select name,associationid from association)ass where ac.associationid=ass.associationid and ac.activityId=#{activityId}")
    ActivityDTO findActivityAndNameById(@Param("activityId")int activityId);

    @Select("select * from activity ac,(select associationid from association where type=#{associationType})ass where ac.associationid=ass.associationid")
    List<Activity> findActivityByAssociationType(@Param("associationType")int associationType);

    @Select("select * from activity ac,(select name,associationid from association where type=#{associationType})ass where ac.associationid=ass.associationid")
    List<ActivityDTO> findActivityAndNameByAssociationType(@Param("associationType")int associationType);

    @Select("select * from activity ac,(select name,associationid from association)ass where ac.associationid=ass.associationid")
    List<ActivityDTO> findAllActivityAndName();

    @Select("select * from activity ac,(select name,associationid from association)ass where ac.associationid=ass.associationid and activitystatus=0")
    List<ActivityDTO> findAllActivityApply();

}
